package com.ronan.common.entity.business;

import com.ronan.common.constant.BusinessConstant;

/**
 * FileName    : com.ronan.common.entity.business
 * Description : body数据的具体对象维护
 *
 * @author : ronan
 * @version : 1.0
 * Create Date : 2021/3/17 14:27
 **/
public enum BusinessEnum {

    GAMEVALUE(BusinessConstant.GAMEVALUE, GameValue.class, "游戏数值");

    private final int code;
    private final Class<? extends Ibus> clazz;
    private final String desc;

    BusinessEnum(int code, Class<? extends Ibus> clazz, String desc) {
        this.code = code;
        this.clazz = clazz;
        this.desc = desc;
    }

    /**
     * 根据code获取类
     *
     * @param code 代码
     * @return {@link Class<? extends Ibus>}
     */
    public static Class<? extends Ibus> getClassByCode(int code) {
        for (BusinessEnum value : BusinessEnum.values()) {
            if (value.code == code) {
                return value.clazz;
            }
        }
        throw new RuntimeException("Not Found class, code: " + code);
    }

}
